import { http } from "@/utils/http";
import { k8sPathMergeReqs, type MergePathReq } from "./apiHelper";
import type { LimitRangeList, ResourceQuota, ResourceQuotaList } from "./types";
import type { BaseResponse } from "@/api/response";

export class K8sResourceQuota {
  baseReq: MergePathReq = {
    src: "resourcequotas",
    app: ""
  };

  create(data: ResourceQuota): BaseResponse {
    const api = k8sPathMergeReqs(this.baseReq);
    return http.post(api, { data });
  }

  // 获取资源配额列表
  listResourceQuotas(args?: MergePathReq): BaseResponse<ResourceQuotaList> {
    const api = k8sPathMergeReqs(args, this.baseReq);
    return http.get(api, { params: args.query });
  }
}

export class K8sLimitRange {
  baseReq: MergePathReq = {
    src: "limitranges",
    app: ""
  };

  create(data: LimitRangeList): BaseResponse {
    const api = k8sPathMergeReqs(this.baseReq);
    return http.post(api, { data });
  }

  listLimitRanges(args?: MergePathReq): BaseResponse<LimitRangeList> {
    const api = k8sPathMergeReqs(args, this.baseReq);
    return http.get(api, { params: args.query });
  }
}
